﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using VOL.Domain.IServices;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.WarehouseManagement
{
    /// <summary>
    /// 采购入库
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PurchaseWarehousingController : ControllerBase
    {
        private readonly IPurchaseWarehousingService  _purchaseWarehousingService;

        public PurchaseWarehousingController(IPurchaseWarehousingService purchaseWarehousingService)
        {
            this._purchaseWarehousingService = purchaseWarehousingService;
        }

        /// <summary>
        /// 采购入库新增
        /// </summary>
        /// <param name="purchaseWarehousing"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddPurchaseWarehousing([FromBody]PurchaseWarehousing purchaseWarehousing)
        {
            return await _purchaseWarehousingService.AddPurchaseWarehousing(purchaseWarehousing);
        }
        /// <summary>
        /// 采购入库显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PurchaseWarehousing>> GetAllPurchaseWarehousing(string? inboundListCode, string? inboundListName, DateTime? inboundListTime, string? informCode, int pageIndex = 1, int pageSize = 5)
        {
           return await _purchaseWarehousingService.GetAllPurchaseWarehousing(inboundListCode, inboundListName, inboundListTime, informCode, pageIndex, pageSize);
        }
        /// <summary>
        /// 采购入库修改
        /// </summary>
        /// <param name="purchaseWarehousing"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdatePurchaseWarehousing([FromBody]PurchaseWarehousing purchaseWarehousing)
        {
            return await _purchaseWarehousingService.UpdatePurchaseWarehousing(purchaseWarehousing);
        }
        /// <summary>
        /// 删除采购入库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> DeletePurchaseWarehousing(int id)
        {
            return await _purchaseWarehousingService.DeletePurchaseWarehousing(id);
        }
    }
}
